<template>
    <div>
        <el-table
                :data="tableData"
                border
                style="width: 95%">
            <el-table-column

                    prop="id"
                    label="问题编号"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="username"
                    label="用户名"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="title"
                    label="问题标题"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="content"
                    label="问题内容"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="ispast"
                    label="是否过审"
                    width="80">
            </el-table-column>
            <el-table-column
                    prop="createtime"
                    label="创建时间"
                    width="200">
            </el-table-column>
            <el-table-column
                    prop="updatetime"
                    label="更新时间"
                    width="200">
            </el-table-column>
            <el-table-column
                    fixed="right"
                    label="操作"
                    width="180">
                <template slot-scope="scope">
                    <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                background
                layout="prev, pager, next"
                :page-size=pageSize
                :total="total"
                :current-page=currentPage
                @current-change=page>
        </el-pagination>
    </div>
</template>

<script>
    export default {
        methods: {
            handleClick(row) {
                const _this = this;
                console.log(row);
                axios.delete("http://localhost:8181/consult/deleteQ/"+row.id).then(function (resp) {
                    if (resp.data.data == 'success'){
                        _this.$message({
                            message: '删除成功！',
                            type: 'success'
                        });
                        window.location.reload();
                    }
                })
            },
            page(currentPage){
                const _this = this
                axios.get("http://localhost:8181/manage/listQ?currentPage="+currentPage).then(function (resp) {
                    _this.tableData = resp.data.data.records
                    _this.total = resp.data.data.total
                    _this.currentPage = resp.data.data.current
                    _this.pageSize = resp.data.data.size
                })
            }
        },
        created() {
            const _this = this
            axios.get("http://localhost:8181/manage/listQ").then(function (resp) {
                _this.tableData = resp.data.data.records
                _this.total = resp.data.data.total
                _this.currentPage = resp.data.data.current
                _this.pageSize = resp.data.data.size
            })
        },
        data() {
            return {
                total: null,
                pageSize: null,
                currentPage: null,
                tableData: [{
                    id: '2016-05-02',
                    username: '王小虎',
                    content: '上海',
                    ispast: '普陀区',
                    createtime: 200333,
                    updatetime: '时间',
                }]
            }
        }
    }
</script>

<style scoped>

</style>